#include "rrprim.h"

RRPrim::RRPrim()
{
    verts_index = 0;
    color[0] = 0.0f;
    color[1] = 0.0f;
    color[2] = 0.0f;
    color[3] = 0.0f;
}

void RRPrim::rrSetType(RRPrimType arg)
{
    t = arg;
}

RRPrimType RRPrim::rrGetType()
{
    return t;
}

void RRPrim::rrSetVert(RRVertex arg)
{
    verts[verts_index] = arg;
    verts_index++;
}

RRVertex RRPrim::rrGetVert(int index)
{
    return verts[index];
}

RRVertex RRPrim::rrGetCurrentVert()
{
    if(verts_index > 0)
        return verts[verts_index-1];
    else
        return verts[0];
}

RRVertex *RRPrim::rrGetVertAdrs(int index)
{
    return &verts[index];
}

int RRPrim::rrGetVertsNum()
{
    return verts_index;
}

float RRPrim::rrGetX(int index)
{
    return verts[index].x;
}

float RRPrim::rrGetY(int index)
{
    return verts[index].y;
}

void RRPrim::rrReset()
{
    verts_index = 0;
    verts[0].x = -10000.0f;
    verts[0].y = -10000.0f;
}

void RRPrim::rrBegin(RRPrimType type)
{
    rrReset();
    rrSetType(type);
}

void RRPrim::rrEnd()
{

}

void RRPrim::rrSetVert3f(float x, float y, float z)
{
    RRVertex temp;
    temp.x = x; temp.y = y; temp.z = z; temp.w = 1.0f;
    temp.c[0] = color[0]; temp.c[1] = color[1];
    temp.c[2] = color[2]; temp.c[3] = color[3];

    rrSetVert(temp);
}

void RRPrim::rrColor4f(float a, float r, float g, float b)
{
    color[0] = a; color[1] = r;
    color[2] = g; color[3] = b;
}
